﻿using ATTools.Services;
using Orchard.Commands;
using Orchard.Environment.Extensions;

namespace ATTools.Commands
{
    [OrchardFeature("ATTools.VoiceCommands")]
    public class VoiceCommandCommands : DefaultOrchardCommandHandler
    {

        private readonly IVoiceCommandService _voiceCommandService;

        public VoiceCommandCommands(IVoiceCommandService voiceCommandService)
        {
            _voiceCommandService = voiceCommandService;
        }

        [OrchardSwitch]
        public string Activation { get; set; }

        [OrchardSwitch]
        public string Data { get; set; }

        [CommandName("voicecommand add gotourl")]
        [CommandHelp("voicecommand add gotourl /Activation:<activation> /Data:<data> \r\n\t" + "Add a voice command that on <activation> goes to the url <data> - Use {value} to get the text that follows the activation")]
        [OrchardSwitches("Activation, Data")]
        public string AddCommandUrl()
        {
            _voiceCommandService.CreateVoiceCommand(Activation, Models.CommandType.GoToUrl, Data);
            return "New Voice Command added successfully";
        }

        [CommandName("voicecommand add javascript")]
        [CommandHelp("voicecommand add javascript /Activation:<activation> /Data:<data> \r\n\t" + "Add a voice command that on <activation> executes the JavaScript <data> - Use {value} to get the text that follows the activation")]
        [OrchardSwitches("Activation, Data")]
        public string AddCommandJavaScript()
        {
            _voiceCommandService.CreateVoiceCommand(Activation, Models.CommandType.JavaScript, Data);
            return "New Voice Command addded successfully";
        }

    }
}